package com.dyava.commons.http;

/**
 * Created by jjliu on 2017/7/22.
 */
public class ResponseBody<T> {
    int code; // 0 正常 其他异常
    String message;
    T data;

    public ResponseBody() {
    }

    public ResponseBody(int code, String message, T data) {
        super();
        this.code = code;
        this.message = message;
        this.data = data;
    }

    public static <T> ResponseBody<T> success(){
        return new ResponseBody<T>(0,null,null);
    }

    public static <T> ResponseBody<T> success(T data){
        return new ResponseBody<T>(0,null,data);
    }

    public static <T> ResponseBody<T> fault(int code, String message){
        return new ResponseBody<T>(code,message,null);
    }

    public int getCode() {
        return code;
    }
    public void setCode(int code) {
        this.code = code;
    }
    public String getMessage() {
        return message;
    }
    public void setMessage(String message) {
        this.message = message;
    }
    public T getData() {
        return data;
    }
    public void setData(T data) {
        this.data = data;
    }

}
